var util = require('../../utils/util.js')

//获取应用实例
var app = getApp()
Page({
  data: {
    button_list:[
      ['无法开锁','action'],
      ['球杆损坏','default'],
      ['无法还杆','default'],
      ['锁损坏','default'],
      ['其它','default']
    ],  
    button: {
      disabled: 'true'
    },
    feedback_type:'无法开锁',
    feedback_content:''
  },

  selectFeedback:function(e){
      var index       = e.currentTarget.id;
      var button_list = this.data.button_list;
      for(var i= 0 ; i< button_list.length;i++){
         button_list[i][1] = i == index ? 'action':'default';
      }
      this.setData({
          button_list   : button_list,
          feedback_type : button_list[index][0]
      })
  },
  bindInput:function(e){
    this.setData({
       feedback_content: e.detail.value
    })
  },
  postFeedback:function(){
     this.setData({
       button: {disabled:'false'}
     })
    
     var session_id       = wx.getStorageSync('session_id');
     var feedback_type    = this.data.feedback_type;
     var feedback_content = this.data.feedback_content;
     var ball_arm_number  = wx.getStorageSync('ball_arm_number') || '';
     //本次消费不计费
     if(ball_arm_number != ''){
       wx.setStorage({
         key: 'user_feedback',
         data: 1
       });
     }
     wx.request({
       url: app.data.servser + '/index/addUserFeedback',
       data: {
         session_id       : session_id,
         feedback_type    : feedback_type,
         feedback_content : feedback_content,
         ball_arm_number  : ball_arm_number

       },
       success: function (res) {
              
       }
     })
     wx.hideLoading();
     wx.showToast({
       title: '提交成功',
       icon: 'success',
       duration: 2000
     });
     setTimeout(function () { wx.navigateBack(1); }, '1500')
  },
  callCustomerService:function(){
    wx.makePhoneCall({
       phoneNumber: '13998344443' //仅为示例，并非真实的电话号码
    })
    wx.request({
      url: app.data.servser + '/index/addUserFeedback',

      data: {
        session_id: wx.getStorageSync('session_id'),
        feedback_type: '人工客服',
        feedback_content:'',
        ball_arm_number: ''

      },
      success: function (res) {

      }
    })
  }
  
})
